fontSize();
$(window).resize(function () {
    fontSize();
});

function fontSize() {
    var size;
    var winW = $(window).width();
    if (winW <= 1500 && winW > 800) {
        size = Math.round(winW / 15);
    } else if (winW <= 800) {
        size = Math.round(winW / 7.5);
        if (size > 65) {
            size = 65;
        }
    } else {
        size = 100;
    }
    $('html').css({
        'font-size': size + 'px'
    })
}

if($(window).width() <= 760){
    $('body').append('<div class="landscape-tips">\n' +
        '    <div class="ico"><img src="image/img200.png" alt=""></div>\n' +
        '    <p>为了更好的体验<br>请将手机旋转90度后竖屏观看</p>\n' +
        '</div>')
}

$(function () {
    loading();
    //--
    setTimeout(function () {
        $('body').addClass('show');
    }, 500);
    //--
    $('.navA').click(function () {
        if ($('body').hasClass('navShow')) {
            $('body').removeClass('navShow')
        } else {
            $('body').addClass('navShow')
        }
    });
    $('.g-nav').find('li').each(function () {
        var _ = $(this);
        if ($(this).find('.list').length > 0) {
            _.find('a.name').click(function () {
                if ($(window).width() > 800) return;
                if (_.hasClass('on')) {
                    _.removeClass('on');
                    _.find('.list').hide();
                } else {
                    _.addClass('on');
                    _.find('.list').show();
                }
                return false;
            })
        }
    });
    //--返回顶部
    scroll2top();

    //--js下拉选择框
    $('.select').each(function () {
        var _this = $(this);
        _this.find('select').change(function () {
            _this.find('span').html($(this).find("option:selected").text());
        })
    });

    bannerFun();

    $('.form').find('.input').each(function () {
        var input = $(this).find('input'),
            text = input.val();
        input.focus(function () {
            if(text === $(this).val()){
                $(this).val("")
            }
        });
        input.blur(function () {
            if($(this).val() === ""){
                $(this).val(text)
            }
        })
    });

    $('#audio').click(function () {
        var video = document.getElementById('myAudio');
        if($(this).hasClass('on')){
            $(this).removeClass('on');
            video.pause()
        }else{
            $(this).addClass('on');
            video.play()
        }
    })

});

function bannerFun() {
    var dom = $('.p-banner');
    dom.mousemove(function (e) {
        var x = e.pageX - dom.width() / 2,
            y = e.pageY - dom.height() / 2;
        dom.find('.bg').css({
            'left': x*.05 + 'px'
        })
    })
}

function swiperFun(swiper) {
    this.dom = swiper.dom;
    this.domList  = this.dom;
    this.dom.find('ul').addClass('swiper-wrapper');
    this.dom.find('li').addClass('swiper-slide');
    if(swiper.domList !== undefined){
        this.domList = this.dom.find(swiper.domList)
    }
    if(this.dom.find('.num').length > 0){
        this.dom.find('.num-total').html(this.dom.find('li').length)
    }

    this.change = function () {};
    var that = this;
    this.mySwiper = new Swiper(that.domList, {
        loop:true,
        autoplay: swiper.autoplay !== undefined ? swiper.autoplay : 5000,
        direction: swiper.direction !== undefined ? swiper.direction : 'horizontal',
        autoplayDisableOnInteraction: false,
        paginationClickable: true,
        speed: 600,
        slidesPerView: swiper.slidesPerView !== undefined ? swiper.slidesPerView : 1,
        centeredSlides: swiper.centeredSlides !== undefined ? swiper.centeredSlides : false,
        pagination: that.dom.find('.dots'),
        onSlideChangeStart: function(swiper){
            if(that.dom.find('.num').length > 0){
                that.dom.find('.num-curr').html(swiper.realIndex + 1)
            }
            that.change(swiper.realIndex);
        }
    });
    this.dom.hover(
        function () {
            that.mySwiper.stopAutoplay()
        },
        function () {
            that.mySwiper.startAutoplay()
        }
    );
    this.dom.find('.prev').click(function () {
        that.mySwiper.slidePrev()
    });
    this.dom.find('.next').click(function () {
        that.mySwiper.slideNext()
    })
}

//--选项卡-- tabFun({dom: $('.about'), curr: 0});
function tabFun(tab) {
    var btn = tab.dom.find('.tab-btn li'),
        box = tab.dom.find('.tab-box');

    btn.each(function (i) {
        $(this).click(function () {
            change(i)
        })
    });

    change(tab.curr);
    function change(curr) {
        btn.removeClass('on');
        btn.eq(curr).addClass('on');
        box.hide();
        box.eq(curr).fadeIn()
    }
}

function scroll2top() {
    var btn = $('.topA');
    btn.click(function () {
        $('body,html').stop(true, true).animate({scrollTop: 0}, 300);
    });
    $(window).scroll(function () {
        if($(window).scrollTop() > $(window).height()){
            btn.addClass('show')
        }else{
            btn.removeClass('show')
        }
        if($(window).scrollTop() > $('.p-banner').height() - $('.g-head').height()){
            $('.g-head').addClass('on')
        }else{
            $('.g-head').removeClass('on')
        }
    });
}

function pageLayerHide() {
    $('.p-layer').removeClass('show');
    $('body').removeClass('noscroll')
}
function pageLayerShow(dom) {
    $(dom).addClass('show');
    $('body').addClass('noscroll')
}

<!--放大，缩小，移动-->
var shopControl = function () {
    this.scale = 1;
    this.currPosition = {x:0, y:0};
    this.touchPosition = {x:0, y:0};
    var that = this;

    var dom = $('.shop-box'),
        shop = dom.find('#shop'),
        small_btn = dom.find('.small'),
        big_btn = dom.find('.big');

    small_btn.click(function () {
        if(that.scale <= 1) return;
        that.scale -= .2;
        shopScale()
    });
    big_btn.click(function () {
        if(that.scale >= 2) return;
        that.scale += .2;
        shopScale()
    });

    function shopScale() {
        shop.css({
            'width': that.scale * 100 + '%'
        })
    }

    var isMove = false,
        currPosition = {x:0, y:0},
        startPosition = {x:0, y:0};
    shop.mousedown(function (e) {
        e.stopPropagation();
        startPosition.x = e.offsetX;
        startPosition.y = e.offsetY;
        isMove = true
    });
    shop.mouseup(function (e) {
        e.stopPropagation();
        isMove = false
    });
    shop.mousemove(function (e) {
        e.stopPropagation();
        if(isMove){
            that.currPosition.x += e.offsetX - startPosition.x;
            that.currPosition.y += e.offsetY - startPosition.y;
            shopMove()
        }
    });

    shop.on('touchstart',function(e) {
        var touch = e.originalEvent.targetTouches[0];
        startPosition.x = touch.pageX - that.touchPosition.x;
        startPosition.y = touch.pageY - that.touchPosition.y;
        isMove = true
    });
    shop.on('touchend',function(e) {
        isMove = false
    });
    shop.on('touchmove',function(e) {
        var touch = e.originalEvent.targetTouches[0];
        if(isMove){
            that.currPosition.x = touch.pageX - startPosition.x;
            that.currPosition.y = touch.pageY - startPosition.y;
            that.touchPosition = that.currPosition;
            shopMove()
        }
    });

    function shopMove() {
        shop.css({
            'left': that.currPosition.x + 'px',
            'top': that.currPosition.y + 'px'
        })
    }

    this.reset = function () {
        that.scale = 1;
        that.currPosition = {x:0, y:0};
        that.touchPosition = {x:0, y:0};
        shopScale();
        shopMove()
    }
};

function loading() {
    $('body').addClass('noscroll');
    var dom = $('.loading'),
        num = 0;

    dom.find('a').click(function () {
        loadOk()
    });
    var time = setInterval(function () {
        if(num >= 100){
            loadOk();
            return
        }
        num ++;
        dom.find('.line i').css({
            "width": num + '%'
        })
    }, 50);

    function loadOk() {
        $('body').removeClass('noscroll');
        if($('.indexFlash').length > 0){
            indexFun()
        }
        if($('#p-banner').length > 0){
            pageBannerFun()
        }
        dom.fadeOut(300);
        clearInterval(time)
    }
}